import { defineStore } from 'pinia'
import dt from '@dt/dt'

const key_project = 'project_info'

export const projectStore = defineStore('project', {
  state: () => {
    return {
      info: dt.session.get(key_project),
    }
  },
  getters: {
    name: (state) => {
      return state.info?.projectName
    },
    id: (state) => {
      return state.info?.id ?? 0
    }
  },
  actions: {
    choice(item) {
      dt.session.set(key_project, item)
      this.info = item
    }
  }
})
